import QtQuick 1.0

Item {
    property alias text: indicator.text
    property alias subText: subtext.text
    property bool enabled: false

    signal work

    anchors.fill: parent

    Column {
        anchors.centerIn: parent
        width: parent.width

        Text {
            id: indicator
            width: parent.width
            horizontalAlignment: Text.AlignHCenter
            font.pixelSize: visual.fontXlarge
            font.bold: true
            color: visual.colorSecondaryForeground
            visible: false
            elide: Text.ElideRight
        }
        Text {
            id: subtext
            width: parent.width
            horizontalAlignment: Text.AlignHCenter
            elide: Text.ElideRight
            font.pixelSize: visual.fontSmall
            color: visual.colorSecondaryForeground
            visible: indicator.visible && text.length
        }
    }

    Timer {
        id: timer
        interval: 100
        repeat: true

        onRunningChanged: {
            if (running)
                indicator.visible = true;
            else
                indicator.visible = false;
        }

        onTriggered: {
            work();
        }
    }

    function start() {
        timer.start();
    }
    function stop() {
        timer.stop();
    }
}
